<!-- home -->
<template>
  <div class="about-container">
    <div class="warpper">
      <div class="list">
        <div class="logo"></div>
        <div class="demo-home__title">YNET前端特训H5模板</div>
        <div class="item">项目作者: 易诚互动</div>
        <div class="form" >
          <van-form @submit="onSubmit">
            <van-field
              v-model="username"
              name="用户名"
              label="用户名"
              placeholder="用户名"
              :rules="[{ required: true, message: '请填写用户名' }]"
            />
            <van-field
              v-model="password"
              type="password"
              name="密码"
              label="密码"
              placeholder="密码"
              :rules="[{ required: true, message: '请填写密码' }]"
            />
            <div style="margin: 16px">
              <van-button round block type="danger" native-type="submit">登录</van-button>
            </div>
          </van-form>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
// 请求接口
import { mapGetters } from 'vuex'

export default {
  data() {
    return {
      username:'ynet',
      password:'admin'
    }
  },
  computed: {
    ...mapGetters(['userName'])
  },
  mounted() {
    this.initData()
  },
  methods: {
    // 请求数据案例
    initData() {
      // 路由传参
    //  console.warn('title',this.$route.params.title)
      this.API.getRequest('MP5005')
        .then(res => {
          console.warn('res', res)
        })
        .catch(err => {
          console.error(err)
        })
    },
    // Action 通过 store.dispatch 方法触发
    doDispatch() {
    },
    // 提交
    onSubmit(){
      this.$toast.success('登录成功');
       this.$store.dispatch('setUserName', 'ynet')
       this.$router.push('/home')
    }
  }
}
</script>
<style lang="scss">
.about-container {
  position: fixed;
  bottom: 0;
  overflow: hidden hidden;
  /* 你的命名空间 */
  background: #fff;
  height: 100vh;
  width: 100%;
  box-sizing: border-box;
  .warpper {
    .list {
      display: flex;
      flex-direction: column;
      align-items: center;
      color: #666;
      font-size: 14px;
      .demo-home__title {
        margin: 0 0 6px;
        font-size: 32px;
        .demo-home__title img,
        .demo-home__title span {
          display: inline-block;
          vertical-align: middle;
        }
      }
      .item {
        font-size: 14px;
        line-height: 34px;
        a {
          text-decoration: underline;
        }
        .van-button {
          /* vant-ui 元素*/
          background: #ff5500;
        }
      }

      .logo {
        height: 120px;
      }
      .form {
        position: fixed;
        bottom: 2rem;
      }
    }
  }
}
</style>
